<?php

/**
 * midia components.
 *
 * @package    sispatr
 * @subpackage midia
 * @author     Foxsis
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class gridComponents extends sfComponentsFoxsis
{
	public function executeJqGrid()
    {
    	$this->colModel	= array();
    	$this->colNames	= array();
    	
    	foreach($this->colunas as $titulo => $model)
    	{
    		$this->colNames[]			= '"'.$titulo.'"';
    		
    		$this->colModel[]			= array(
    											'name'	=> $model,
    											'index'	=> $model,
    											'width'	=> 960/count($this->colunas),
    											'align'	=> ($model == 'act') ? "center" : "left",
    											);
    	} 
    	
    	$this->actions	= implode(" ", $this->actions);
    	
    	$this->colModel	= json_encode($this->colModel);
    	
    	$this->colNames	= implode(",", $this->colNames);
    	$this->colNames	= "[".$this->colNames."]";
    }
    
	public function executeDataTable()
    {
    	$this->aoColumns	= array();
    	
    	$i = 0;
    	foreach($this->colunas as $cols)
    	{
    		$this->aoColumns[$i]['mDataProp']	= $cols;
    		$this->aoColumns[$i]['sName']		= $cols;
    		
    		$i++;
    	}
    	
    	$this->aoColumns	= json_encode($this->aoColumns);
	
    	$this->col_names	= implode(',', $this->colunas);
    	
    	$this->url_grid		= (isset($this->url)) ? $this->url : 'grid';
    }
}